<?php

/*
	Class: Countries

	About: Author
		J William McCarthy

	About: License
		<http://communit.as/docs/license>

	About: See Also
	 	<App_Db_Table_Abstract>
*/
class Countries extends App_Db_Table_Abstract {

    protected $_name 	= 'default_countries';
    protected $_primary = 'country_code';

	/* Group: Instance Methods */

	/*
		Function: getCountriesArray
			Gets an array of countries from the database.

		Arguments:
			nullval (optional) - A string to describe the first entry in the returned array which will have a null value. Default is "Any".

		Returns:
			An array of key-value pairs representing countries.
	*/
    public function getCountriesArray($nullval = "Any"){
    	$countries = array();
    	$countries[null] = $nullval;
    	$db_countries = $this->fetchAll(null, 'country');
    	foreach ($db_countries as $country) {
    		$countries[$country->country_code] = $country->country;
    	}
    	return $countries;
    }

	/*
		Function: getRegionsArray
			Gets an array of regions from the database. Typically continents.

		Arguments:
			nullval (optional) - A string to describe the first entry in the returned array which will have a null value. Default is "Any".

		Returns:
			An array of key-value pairs representing regions.
	*/
    public function getRegionsArray($nullval = "Any"){
    	$regions = array();
    	$regions[null] = $nullval;
    	$regions['AF'] = "Africa";
    	$regions['AS'] = "Australia";
    	$regions['EU'] = "Europe";    	
    	$regions['NA'] = "North America";
    	$regions['SA'] = "South America";
    	$regions['OC'] = "Oceania";
    	return $regions;
    }
}
